﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace Microhard.Core.DBUtility
{
    public static class DataSetExtension
    {
        public static object[] AsEnumerable(this DataTable dataTable, Type desType)
        {
            if (dataTable == null)
                return null;
            object[] rtn = new object[dataTable.Rows.Count];
            for(int i = 0; i<dataTable.Rows.Count ;i++)
            {
                var value = AutoMapper.Mapper.DynamicMap(dataTable.Rows[i], typeof(DataRow), desType);
                rtn[i] = value;
            }
            return rtn;
        }
    }
}
